home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SOURCE.BIN / Demo.java < prev    next >
Encoding:
Java Source  |  1997-06-19  |  2.6 KB  |  151 lines

  1. package symantec.itools.demo;
  2.  
  3.  
  4. import java.applet.Applet;
  5. import java.awt.Component;
  6. import java.awt.FlowLayout;
  7. import java.awt.Font;
  8. import java.awt.Graphics;
  9. import java.awt.LayoutManager;
  10. import symantec.itools.awt.util.Util;
  11.  
  12.  
  13. /**
  14.  *
  15.  *
  16.  *
  17.  * @see
  18.  *
  19.  * @version 1.0, Nov 26, 1996
  20.  *
  21.  * @author    Symantec
  22.  *
  23.  */
  24.  
  25.  
  26. public abstract class Demo
  27.     extends Applet
  28. {
  29.     protected String       title;
  30.     protected boolean      isApplet;
  31.     protected DemoFrame    frame;
  32.     protected int          xPos;
  33.     protected int          yPos;
  34.     protected int          width;
  35.     protected int          height;
  36.  
  37.     public Demo(String s, int x, int y, int w, int h)
  38.     {
  39.         title  = s;
  40.         xPos   = x;
  41.         yPos   = y;
  42.         width  = w;
  43.         height = h;
  44.     }
  45.  
  46.     public void init()
  47.     {
  48.         isApplet = true;
  49.         setup();
  50.         frame.show();
  51.     }
  52.  
  53.     protected void driver()
  54.     {
  55.         isApplet = false;
  56.         setup();
  57.         frame.show();
  58.     }
  59.  
  60.     protected void setup()
  61.     {
  62.         frame = new DemoFrame(this, title);
  63.         frame.reshape(xPos, yPos, width, height);
  64.         frame.setLayout(new FlowLayout());
  65.     }
  66.  
  67.     public void endDemo()
  68.     {
  69.         if(isApplet)
  70.         {
  71.             stop();
  72.         }
  73.         else
  74.         {
  75.             System.exit(0);
  76.         }
  77.     }
  78.  
  79.     public void cleanup()
  80.     {
  81.            frame.hide();
  82.         frame.dispose();
  83.     }
  84.  
  85.     public void doExit()
  86.     {
  87.         cleanup();
  88.         endDemo();
  89.     }
  90.  
  91.     public void doHelp()
  92.     {
  93.     }
  94.  
  95.     public void doAbout()
  96.     {
  97.     }
  98.  
  99.     public void doRestart()
  100.     {
  101.         cleanup();
  102.         setup();
  103.     }
  104.  
  105.     public Component add(Component c)
  106.     {
  107.         return (frame.add(c));
  108.     }
  109.  
  110.     public synchronized Component add(Component c, int i)
  111.     {
  112.         return (frame.add(c, i));
  113.     }
  114.  
  115.     public synchronized Component add(String s, Component c)
  116.     {
  117.         return (frame.add(s, c));
  118.     }
  119.  
  120.     public void setLayout(LayoutManager manager)
  121.     {
  122.         if(frame != null)
  123.         {
  124.             frame.setLayout(manager);
  125.         }
  126.     }
  127.  
  128.     public Graphics getGraphics()
  129.     {
  130.         return frame.getGraphics();
  131.     }
  132.  
  133.     public Font getFont()
  134.     {
  135.         Font font;
  136.  
  137.         if(frame != null)
  138.         {
  139.             font = frame.getFont();
  140.  
  141.             font = (font == null) ? Util.getDefaultFont() : font;
  142.         }
  143.         else
  144.         {
  145.             font = Util.getDefaultFont();
  146.         }
  147.  
  148.         return font;
  149.     }
  150. }
  151.